part of '../repository.dart';

const _kAbsentPurchasedSubscriptionPriceIncreaseStatusValue = 'absent';
const _kPendingPurchasedSubscriptionPriceIncreaseStatusValue = 'pending';
const _kAcceptedPurchasedSubscriptionPriceIncreaseStatusValue = 'accepted';

class _PurchasedSubscriptionPriceIncreaseStatusDto extends Equatable {
  const _PurchasedSubscriptionPriceIncreaseStatusDto._internal({
    required this.priceIncreaseStatusString,
  });

  final String priceIncreaseStatusString;

  @override
  List<Object?> get props {
    return [
      priceIncreaseStatusString,
    ];
  }

  factory _PurchasedSubscriptionPriceIncreaseStatusDto.fromString(
      String priceIncreaseStatusString) {
    return _PurchasedSubscriptionPriceIncreaseStatusDto._internal(
      priceIncreaseStatusString: priceIncreaseStatusString,
    );
  }

  factory _PurchasedSubscriptionPriceIncreaseStatusDto.fromEntity(
      AppStorePurchasedSubscriptionPriceIncreaseStatus priceIncreaseStatus) {
    late final String priceIncreaseStatusString;

    if (priceIncreaseStatus == AppStorePurchasedSubscriptionPriceIncreaseStatus.absent) {
      priceIncreaseStatusString = _kAbsentPurchasedSubscriptionPriceIncreaseStatusValue;
    } else if (priceIncreaseStatus == AppStorePurchasedSubscriptionPriceIncreaseStatus.pending) {
      priceIncreaseStatusString = _kPendingPurchasedSubscriptionPriceIncreaseStatusValue;
    } else if (priceIncreaseStatus == AppStorePurchasedSubscriptionPriceIncreaseStatus.accepted) {
      priceIncreaseStatusString = _kAcceptedPurchasedSubscriptionPriceIncreaseStatusValue;
    }

    return _PurchasedSubscriptionPriceIncreaseStatusDto._internal(
      priceIncreaseStatusString: priceIncreaseStatusString,
    );
  }

  @override
  String toString() {
    return priceIncreaseStatusString;
  }

  AppStorePurchasedSubscriptionPriceIncreaseStatus toEntity() {
    if (priceIncreaseStatusString == _kAbsentPurchasedSubscriptionPriceIncreaseStatusValue) {
      return AppStorePurchasedSubscriptionPriceIncreaseStatus.absent;
    }

    if (priceIncreaseStatusString == _kPendingPurchasedSubscriptionPriceIncreaseStatusValue) {
      return AppStorePurchasedSubscriptionPriceIncreaseStatus.pending;
    }

    if (priceIncreaseStatusString == _kAcceptedPurchasedSubscriptionPriceIncreaseStatusValue) {
      return AppStorePurchasedSubscriptionPriceIncreaseStatus.accepted;
    }

    throw UnimplementedError();
  }
}
